package _14扫雷;

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// 如果输入行号和列号来表示你要走的位置；如果是地雷，就输出“雷炸了”，如果不是地雷就输出“你周围一圈有N个地雷，请小心!”
		// 输入行号：3
		// 输入列号：3
		// 雷炸了
		// 或 输入行号：4
		// 输入列号：3
		// 你周围一圈有4颗雷，请小心！
		Scanner input = new Scanner(System.in);
		int[][] a = {   { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 
						{ 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0 },
						{ 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0 }, 
						{ 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0 },
						{ 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0 }, 
						{ 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0 },
						{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 
						{ 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 },
						{ 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0 }, 
						{ 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0 },
						{ 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, };
		System.out.print("输入行号：");
		int m = input.nextInt();
		System.out.print("输入列号：");
		int n = input.nextInt();
		if (m > 11 || m < 1 || n > 11 || n < 1) {
			System.out.println("输出的行或者列超出棋盘的范围！");
			return;
		}
		if (a[m - 1][n - 1] == 1) {
			System.out.println("雷炸了！");
		} else {
			int f = 0;
			if (m >= 2 && m <= 10 && n >= 2 && n <= 10) {
				for (int i = m - 2; i <= m; i++) {
					for (int j = n - 2; j <= n; j++) {
						if (a[i][j] == 1) {
							f++;
						}
					}
				}
			} else if (m == 1 && n < 11 && n > 1) {
				for (int i = m - 1; i <= m; i++) {
					for (int j = n - 2; j <= n; j++) {
						if (a[i][j] == 1) {
							f++;
						}
					}
				}
			} else if (n == 1 && m < 11 && m > 1) {
				for (int i = m - 2; i <= m; i++) {
					for (int j = n - 1; j <= n; j++) {
						if (a[i][j] == 1) {
							f++;
						}
					}
				}
			} else if (n == 11 && m < 11 && m > 1) {
				for (int i = m - 2; i <= m; i++) {
					for (int j = n - 2; j <= n - 1; j++) {
						if (a[i][j] == 1) {
							f++;
						}
					}
				}
			} else if (m == 11 && n < 11 && n > 1) {
				for (int i = m - 2; i <= m - 1; i++) {
					for (int j = n - 2; j <= n; j++) {
						if (a[i][j] == 1) {
							f++;
						}
					}
				}
			} else if (m == 1 && n == 11) {
				for (int i = m - 1; i <= m; i++) {
					for (int j = n - 2; j <= n - 1; j++) {
						if (a[i][j] == 1) {
							f++;
						}
					}
				}
			} else if (m == 11 && n == 1) {
				for (int i = m - 2; i <= m - 1; i++) {
					for (int j = n - 1; j <= n; j++) {
						if (a[i][j] == 1) {
							f++;
						}
					}
				}
			} else if (m == 1 && n == 1) {
				for (int i = m - 1; i <= m; i++) {
					for (int j = n - 1; j <= n; j++) {
						if (a[i][j] == 1) {
							f++;
						}
					}
				}
			} else if (m == 11 && n == 11) {
				for (int i = m - 2; i <= m - 1; i++) {
					for (int j = n - 2; j <= n - 1; j++) {
						if (a[i][j] == 1) {
							f++;
						}
					}
				}
			}
			System.out.println("你周围一圈有" + f + "颗雷，请小心！");
		}
	}
}
